<style>
    div[lay-id='storageInventoryInoutSpaceTable']{
        display: none;
    }
    .inventory-space-list{
        display: inline-flex;
        width: 100%;
        flex-wrap: wrap;
    }
    .inventory-space-list .list-cell{
        width: 25%;
        padding: 8px;
        box-sizing: border-box;
    }
    .inventory-space-list .list-cell .list-item{
        border-radius: 5px;
        border: 1px solid #ECECEC;
    }
    .inventory-space-list .list-cell .list-top{
        height: 40px;
        padding-right: 15px;
        background: rgba(0,156,94,0.06);
        border-radius: 5px 5px 0 0;
    }
    .inventory-space-list .list-cell .list-top .sku-name{
        font-weight: 600;
    }
    .inventory-space-list .list-cell .list-top .space{
        flex: 1;
        padding-left: 10px;
        text-align: right;
    }
    .inventory-space-list .list-ct{
        display: flex;
        padding: 15px 15px 5px;
    }
    .inventory-space-list .list-ct .list-icon{
        width: 80px;
        height: 80px;
        flex-shrink: 0;
    }
    .inventory-space-list .list-ct .list-icon img{
        width: 100%;
        height: 100%;
        border-radius: 5px;
        cursor: pointer;
    }
    .inventory-space-list .list-ct .list-txt{
        padding-left: 14px;
        flex: 1;
    }
    .inventory-space-list .list-ct .list-txt .sku-code{
        font-weight: 600;
        line-height: 18px;
        margin-bottom: 2px;
    }
    .inventory-space-list .list-ct .list-txt .label{
        padding-top: 2px;
        line-height: 18px;
    }
    .inventory-space-list .list-btm{
        padding: 0 15px 15px;
    }
    .inventory-space-list .list-btm .nape-cell {
        line-height: 18px;
        padding-top: 10px;
    }
    .inventory-space-list .list-btn{
        padding: 15px 8px;
    }
    .inventory-space-list .list-btn .btn-cell{
        padding: 0 7px;
        flex: 1;
    }
    .inventory-space-list .list-btn .btn-cell .layui-btn{
        width: 100%;
        height: 40px;
        line-height: 40px;
    }
    .inventory-space-list .list-btn .btn-cell .layui-btn.details{
        background-color: #FFFFFF !important;
        color: #333;
        border: 1px solid #009C5E;
    }
    .inventory-space-list .row-between{
        justify-content: space-between;
    }
    .inventory-space-list .flex-ct{
        display: flex;
        align-items: center;
    }
    .inventory-space-list .label{
        color: #999;
    }
    .inventory-space-list .line-1{
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        -o-text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        /*! autoprefixer: ignore next */
        -webkit-box-orient: vertical;
        word-wrap: break-word;
        word-break: break-all;
    }
    .inventory-space-list .list-cell .list-top .space-cion{
        width: 52px;
        height: 32px;
        line-height: 32px;
        color: #FFFFFF;
        padding-left: 15px;
        font-weight: 600;
        background-image: url(assets/images/cabinet/space-icon.png);
        background-size: 100% 100%;
        flex-shrink: 0;
    }
    .cabCodeBox xm-select {
        min-height: 32px;
        line-height: 32px;
        border-radius: 4px;
    }
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 头部操作栏 -->
            <div class="layui-form lay-header">
                <div class="toolbar">
                    <div class="layui-form-item lay-query-content">
                        <div class="lay-query-box">
                            <div class="query-lt" style="width: 56%;">
                                <div class="layui-inline cabCodeBox">
                                    <label class="layui-form-label w-auto">柜子：</label>
                                    <div class="layui-input-inline">
                                        <input type="hidden" name="cabCode" />
                                        <input type="hidden" name="belongCabinet" />
                                        <div id="cabCode"></div>
                                       <!-- <select  name="cabCode" lay-filter="cabCode"  lay-search lay-verify="">
                                            <option value="">请选柜子</option>
                                        </select>-->
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">货道编号：</label>
                                    <div class="layui-input-inline">
                                        <input name="spaceCode" class="layui-input" type="text" placeholder="请输入货道编号" autocomplete="off"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">物料编号：</label>
                                    <div class="layui-input-inline">
                                        <input name="skuCode" class="layui-input" type="text" placeholder="请输入物料编号" autocomplete="off"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">规格码：</label>
                                    <div class="layui-input-inline">
                                        <input name="oldSpecCode" class="layui-input" type="text" placeholder="请输入规格码" autocomplete="off"/>
                                    </div>
                                </div>
                            </div>
                            <div class="query-rt">
                                <div class="layui-inline">
                                    <div class="viewNav" id="viewNav">
                                        <div class="viewNavGraphics active"><img src="assets/images/navgraphics1.png">图文</div>
                                        <div class="viewNavList"><img src="assets/images/navlist.png">列表</div>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog" lay-submit layui-form-keyDownSearch="true">查询</button>
                                    <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置</button>
                                    <button id="cellInventorySpaceExport" class="layui-btn icon-btn"><i class="layui-icon">&#xe67d;</i>导出</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 表格 -->
            <table class="layui-table" id="storageInventoryInoutSpaceTable" lay-filter="storageInventoryInoutSpaceTable"></table>
            <div class="viewNavMain" id="viewNavMain">
                <div class="viewNavBox" style="">
                    <div class="inventory-space-list" id="viewNavBox">
                        
                    </div>
                    <div class="list-none-data" style="display: none">
                        <img src="assets/images/none-data.png" alt="">
                        <p>暂无数据</p>
                    </div>
                </div>
                <div id="viewNavPage" style="text-align: right;"></div>
            </div>
        </div>
    </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="storageInventoryInoutSpaceTableBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit">修改</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/html" id="inventoryProductSpaceTemplate">
    {{# layui.each(d, function(index, item){ }}
    <div class="list-cell">
        <div class="list-item">
            <div class="list-top flex-ct row-between">
                <div class="space-cion">
                    <span>{{item.spaceCode}}</span>
<!--                    <img src="assets/images/cabinet/space-icon.png" alt="">-->
                </div>
                <div class="space line-1"><label class="label">柜子编号：</label><span>{{item.cabCode}}</span></div>
            </div>
            <div class="list-ct">
                <div class="list-icon">
                    <img src="{{item.skuPic || 'assets/images/default-icon.png'}}" alt="">
                </div>
                <div class="list-txt">
                    <div class="sku-code line-1">{{item.skuName}}</div>
                    <div class="label line-1">编码：{{item.skuCode}}</div>
                    <div class="label line-1">规格：{{item.skuSpecOld}}</div>
                    <div class="label line-1">品牌：{{item.productBrandName}}</div>
                </div>
            </div>
            <div class="list-btm">
                <div class="nape-cell flex-ct">
                    <div class="nape-item"><label class="label">柜子名称：</label><span>{{item.cabName}}</span></div>
                </div>
                <div class="nape-cell flex-ct row-between">
                    <div class="nape-item"><label class="label">包装规格：</label><span>{{item.packName}}</span></div>
                    <div class="nape-item"><label class="label">库存(包装计)：</label><span>{{item.quantity}}{{item.unitName}}</span></div>
                </div>
                <div class="nape-cell flex-ct row-between">
                    <div class="nape-item"><label class="label">最大库存(包装计)：</label><span>{{item.quantityMax}}{{item.unitName}}</span></div>
                    <div class="nape-item"><label class="label">库存(基础单位计)：</label><span>{{item.quantityPack}}{{item.basicsUnitName}}</span></div>
                </div>
                <div class="nape-cell flex-ct">
                    <div class="nape-item"><label class="label">主柜编号：</label><span>{{item.belongCabinet}}</span></div>
                </div>
            </div>
        </div>
    </div>
    {{# }); }}
</script>
<!-- 表单弹窗 -->
<script type="text/html" id="storageInventoryInoutForm">
    <form lay-filter="storageInventoryInoutForm" class="layui-form model-form">
        <input name="id" type="hidden"/>
        <div class="layui-form-item">
            <label class="layui-form-label">创建者</label>
            <div class="layui-input-block">
                <input name="creator" placeholder="请输入创建者" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">修改者</label>
            <div class="layui-input-block">
                <input name="modifier" placeholder="请输入修改者" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">创建人</label>
            <div class="layui-input-block">
                <input name="creatorName" placeholder="请输入创建人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">修改人</label>
            <div class="layui-input-block">
                <input name="modifierName" placeholder="请输入修改人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">存刀任务编号</label>
            <div class="layui-input-block">
                <input name="code" placeholder="请输入存刀任务编号" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">no</label>
            <div class="layui-input-block">
                <input name="no" placeholder="请输入no" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">day</label>
            <div class="layui-input-block">
                <input name="day" placeholder="请输入day" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">操作类型</label>
            <div class="layui-input-block">
                <select name="operationType">
                        <option value="in">存刀</option>
                        <option value="out">取刀</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">业务类型</label>
            <div class="layui-input-block">
                <select name="businessType">
                        <option value="temp">暂存</option>
                        <option value="repair">报修</option>
                        <option value="recycle">回收</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <select name="status">
                        <option value="created">已创建/待盘验</option>
                        <option value="checked">已盘验</option>
                        <option value="notified">已通知/回收中</option>
                        <option value="taked">平台已取货/已回收</option>
                        <option value="signed">已签收/已完成</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">盘验人id</label>
            <div class="layui-input-block">
                <input name="checkUserId" placeholder="请输入盘验人id" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">盘验人</label>
            <div class="layui-input-block">
                <input name="checkUserName" placeholder="请输入盘验人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">通知人</label>
            <div class="layui-input-block">
                <input name="notifyUserId" placeholder="请输入通知人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">通知人</label>
            <div class="layui-input-block">
                <input name="notifyUserName" placeholder="请输入通知人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">回收人id</label>
            <div class="layui-input-block">
                <input name="takeUserId" placeholder="请输入回收人id" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">回收人</label>
            <div class="layui-input-block">
                <input name="takeUserName" placeholder="请输入回收人" type="text" class="layui-input" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="storageInventoryInoutFormSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>

<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin','laypage', 'laytpl'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var laypage = layui.laypage;
        var laytpl = layui.laytpl;
        let viewNavPageCount = 0, listText = 1; //viewNavPageCount(图文状态下的页码)  listText(区分图文视图1 和 列表视图0)

        // 渲染表格
        var insTb = table.render({
            elem: '#storageInventoryInoutSpaceTable',
            url: config.base + 'enterprisecab/cabinet/admin/cellInventorySpace/list',
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers', title: '序号', fixed: 'left'}
                ,{field: 'skuName', sort: true, title: '物料名称', fixed: 'left', width: 160}
                ,{field: 'skuCode', sort: true, title: '物料编号', fixed: 'left', width: 160}
                ,{field: 'skuSpecOld', sort: true, title: '规格码', fixed: 'left', width: 160}
                ,{field: 'productBrandName', sort: true, title: '品牌'}
                ,{field: 'spaceCode', sort: true, title: '货道编号'}
                ,{field: 'cabCode', sort: true, title: '柜子编号'}
                ,{field: 'belongCabinet', sort: true, title: '主柜编号', width: 180}
                ,{field: 'cabName', title: '柜子名称', width: 130}
                ,{field: 'quantity', sort: true, title: '库存(包装计)', width: 120}
                ,{field: 'unitName', sort: true, title: '包装单位'}
                ,{field: 'packName', sort: true, title: '包装规格'}
               /* ,{field: 'quantityPack', sort: true, title: '库存(基础单位计)', width: 150, templet: (d)=> {
                    return d.quantityPack + d.basicsUnitName
                }}*/
                ,{field: 'quantityPack', sort: true, title: '库存(基础单位计)', width: 150}
                ,{field: 'basicsUnitName', sort: true, title: '基础单位', templet: d=> d.basicsUnitName ? d.basicsUnitName : '无'}
                ,{field: 'quantityMax', sort: true, title: '货道容量(包装计)', width: 150}

                // ,{field: 'no', sort: true, title: 'no'}
                // ,{field: 'day', sort: true, title: 'day'}
                // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                // ,{field: 'statusDesc', sort: true, title: '状态'}
                // ,{field: 'checkTime', sort: true, title: '盘验时间'}
                // ,{field: 'checkUserId', sort: true, title: '盘验人id'}
                // ,{field: 'checkUserName', sort: true, title: '盘验人'}
                // ,{field: 'notifyTime', sort: true, title: '通知时间'}
                // ,{field: 'notifyUserId', sort: true, title: '通知人'}
                // ,{field: 'notifyUserName', sort: true, title: '通知人'}
                // ,{field: 'takeUserId', sort: true, title: '回收人id'}
                // ,{field: 'takeUserName', sort: true, title: '回收人'}
                // ,{field: 'takeTime', sort: true, title: '回收时间'}
                // ,{field: 'inoutId', sort: true, title: '暂存柜存刀id'}
                // ,{field: 'cabId', sort: true, title: '柜子id'}
                // ,{field: 'skuId', sort: true, title: 'sku id'}
                // ,{field: 'companyId', sort: true, title: '企业id'}
                // ,{field: 'spaceId', sort: true, title: '货道id'}
                // ,{field: 'operationTypeDesc', sort: true, title: '操作类型'}
                // ,{field: 'businessTypeDesc', sort: true, title: '业务类型'}
                // ,{field: 'quantityCurrent', sort: true, title: '当前库存'}
                // ,{field: 'quantityAfter', sort: true, title: '变动后库存'}

                // ,{align: 'center', toolbar: '#storageInventoryInoutSpaceTableBar', title: '操作', width: 200}
            ]],

        });

        // 工具条点击事件
        table.on('tool(storageInventoryInoutSpaceTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') { //修改
                showEditModel(data);
            } else if (obj.event === 'del') { // 删除
                doDelete(obj);
            }
        });

        //监听排序
        table.on('sort(storageInventoryInoutSpaceTable)', function(obj){
            table.reload('storageInventoryInoutSpaceTable', {
                initSort: obj
                ,where: {
                    sort: obj.field
                    ,order: obj.type
                }
            });
            $('[lay-id="storageInventoryInoutSpaceTable"]').show();
        });
        $('#viewNav .viewNavGraphics ').click(function () {
            listText = 1;
            $(this).addClass('active').siblings().removeClass('active');
            $(this).find('img').attr('src', 'assets/images/navgraphics1.png');
            $(this).siblings('div').eq(0).find('img').attr('src', 'assets/images/navlist.png');
            $('[lay-id="storageInventoryInoutSpaceTable"]').hide();
            $('#viewNavMain').show();
        });

        $('#viewNav .viewNavList ').click(function () {
            listText = 0;
            $('[lay-id="storageInventoryInoutSpaceTable"]').show();
            table.resize("storageInventoryInoutSpaceTable");
            $('#viewNavMain').hide();
            $(this).addClass('active').siblings().removeClass('active');
            $(this).find('img').attr('src', 'assets/images/navlist1.png');
            $(this).siblings('div').eq(0).find('img').attr('src', 'assets/images/navgraphics.png');
        });

        function viewNavBox(data) {
            layer.load(2);
            if (!data || data.length <= 0) {
                $('#viewNavBox').html('');
                $(".list-none-data").show();
                $('#viewNavPage').hide();
            }else {
                $(".list-none-data").hide();
                $('#viewNavPage').show();
                laytpl(inventoryProductSpaceTemplate.innerHTML).render(data, function (html) {
                    $('#viewNavBox').html(html);
                });
            }
            layer.closeAll();
        }
        admin.reqSync('enterprisecab/cabinet/admin/cellInventorySpace/list', {page: 1, limit: 12}, res => {
            if (res.code === 200) {
                viewNavPageCount = res.count;
                viewNavBox(res.data);
                viewNavPageFn()
            }
        }, 'get');

        function viewNavPageFn(_condition) {
            laypage.render({
                elem: 'viewNavPage' //注意，这里的 test1 是 ID，不用加 # 号
                , count: viewNavPageCount //数据总数，从服务端得到
                , limit: 12
                , jump: function (obj, first) {
                    if (!first) {
                        let condition = _condition ? $.extend(_condition, {
                            page: obj.curr,
                            limit: obj.limit
                        }) : {page: obj.curr, limit: obj.limit};
                        admin.req('enterprisecab/cabinet/admin/cellInventorySpace/list', condition, res => {
                            if (res.code === 200) {
                                viewNavBox(res.data);
                            }
                        }, 'get');
                    }
                }
            });
        }

        // 搜索
        form.on('submit(formSubSearchLog)', function (data) {
            if (listText == 0) {
                insTb.reload({where: data.field,page: {curr: 1}},'data');
                $('[lay-id="storageInventoryInoutSpaceTable"]').show();
            } else {
                admin.reqSync('enterprisecab/cabinet/admin/cellInventorySpace/list', $.extend(data.field, {
                    page: 1,
                    limit: 12
                }), res => {
                    if (res.code === 200) {
                        viewNavPageCount = res.count;
                        viewNavBox(res.data);
                        viewNavPageFn(data.field)
                    }
                }, 'get');
            }
        });

        // 重置搜索
        form.on('submit(resets)', function (data) {
            cabCodeXmSelect.setValue([ ]);
            $(".lay-header").find('select').val("");
            $(".lay-header").find('input').val("");
            var field = data.field;
            for(let key in field){
                field[key] = ''
            }
            if (listText == 0) {
                insTb.reload({where: field,page: {curr: 1}},'data');
                $('[lay-id="storageInventoryInoutSpaceTable"]').show();
            }else {
                admin.reqSync('enterprisecab/cabinet/admin/cellInventorySpace/list', {page: 1,limit: 12}, res => {
                    if (res.code === 200) {
                        viewNavPageCount = res.count;
                        viewNavBox(res.data);
                        viewNavPageFn(field)
                    }
                }, 'get');
            }
        });

        let arr2treeExt = [],cabCodeXmSelect;
        admin.req('enterprisecab/cabinet/admin/cabinet/list',{cabinetType:'spring',limit:9999,menuType:'neckNew'},res=>{
            if(res.code === 200){
                for (let i = 0; i < res.data.length; i++) {
                    res.data[i].children = [];
                    if(res.data[i].cabinetNature == 'main'){
                        res.data[i].changeName =  res.data[i].cabCode
                    }else {
                        res.data[i].changeName =  res.data[i].code
                    }
                }
                arr2treeExt = xmSelect.arr2tree(res.data, "belongCabinet", "cabCode", "children", -1);
            }

            cabCodeXmSelect = xmSelect.render({
                el: '#cabCode',
                radio: true,
                model: {label: {type: 'text'}},
                clickClose: true,
                height:'200px',
                tree: {
                    show: true,
                    strict: false,
                    expandedKeys: [-1],
                },
                tips: '请选择柜子',
                prop: {
                    name: 'changeName',
                    value: 'id',
                    children: 'children'
                },
                data() {
                    //填充数据
                    return arr2treeExt;
                },
                on: function (data) {
                    let id = '',arrIds = [];
                    if(data.arr.length>0){
                        for (let j = 0; j < data.arr.length; j++) {
                            if (data.arr[j].cabinetNature == 'main') {
                                id = data.arr[j].cabCode;
                                $(".cabCodeBox input[name='cabCode']").val(undefined);
                                $(".cabCodeBox input[name='belongCabinet']").val(id);
                                /* arrIds = data.arr[j].children.map(item => item.code);
                                 id = arrIds.length === 0 ? data.arr[j].cabCode : arrIds.toString();*/
                            } else {
                                id = data.arr[j].code;
                                $(".cabCodeBox input[name='cabCode']").val(id);
                                $(".cabCodeBox input[name='belongCabinet']").val(undefined);

                            }
                            // $(".cabCodeBox input[name='cabCode']").val(id);
                        }
                    }else {
                        $(".cabCodeBox input[name='cabCode']").val('');
                        $(".cabCodeBox input[name='belongCabinet']").val('');
                    }
                    $('[lay-filter="formSubSearchLog"]').click();
                }
            });
        });

        /*admin.req('enterprisecab/cabinet/admin/cabinet/list', {limit:999,cabinetNature:'sale',cabinetType:'spring'}, function (res) {
            if (200 == res.code) {
                var optionHtml='<option value=""> 请选择柜子</option>';
                for(var k=0;k<res.data.length;k++){
                    optionHtml+='<option value="'+res.data[k].code+'">'+res.data[k].code+'</option>';
                }
                $("select[name='cabCode']").html(optionHtml);
                form.render('select')
            } else {
                layer.msg(res.msg, {icon: 2, time: 1000});
            }
        }, 'GET');*/

        form.render('select');

        // 添加按钮点击事件
        $('#storageInventoryInoutBtnAdd').click(function () {
            showEditModel();
        });

        // 显示编辑弹窗
        function showEditModel(data) {
            admin.open({
                type: 1,
                area: '880px',
                offset: '65px',
                title: data ? '修改暂存柜存刀/取刀;存/取报修/回收刀' : '添加暂存柜存刀/取刀;存/取报修/回收刀',
                content: $('#storageInventoryInoutForm').html(),
                success: function () {
                    if (data){
                        var option = $("form select[name='operationType']").find("option");
                        layui.each(option, function(index, item){
                            if(data.operationType  == item.text){
                                data.operationType = item.value;
                            }
                        });
                    }

                    if (data){
                        var option = $("form select[name='businessType']").find("option");
                        layui.each(option, function(index, item){
                            if(data.businessType  == item.text){
                                data.businessType = item.value;
                            }
                        });
                    }

                    if (data){
                        var option = $("form select[name='status']").find("option");
                        layui.each(option, function(index, item){
                            if(data.status  == item.text){
                                data.status = item.value;
                            }
                        });
                    }

                    form.val('storageInventoryInoutForm', data);
                    // 表单提交事件
                    form.on('submit(storageInventoryInoutFormSubmit)', function (d) {
                        layer.load(2);
                        admin.req(data ? 'enterprisecab/cabinet/admin/storageInventoryInout/update' : 'enterprisecab/cabinet/admin/storageInventoryInout/add', d.field, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('storageInventoryInoutSpaceTable');
                                layer.closeAll('page');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, data ? 'PUT' : 'POST');
                        return false;
                    });
                }
            });
        }

        // 删除
        function doDelete(obj) {
            layer.confirm('确定要删除吗？', {
                offset: '65px',
                skin: 'layui-layer-admin'
            }, function (i) {
                layer.close(i);
                layer.load(2);
                admin.req('enterprisecab/cabinet/admin/storageInventoryInout/' + obj.data.id, {}, function (res) {
                    layer.closeAll('loading');
                    if (res.code == 200) {
                        layer.msg(res.msg, {icon: 1});
                        obj.del();
                    } else {
                        layer.msg(res.msg, {icon: 2});
                    }
                }, 'DELETE');
            });
        }

        // 导出按货道库存数据
        $('#cellInventorySpaceExport').click(function () {

            location.href = config.base + 'enterprisecab/cabinet/admin/cellInventorySpace/export';
        });

    });
</script>